package com.dataguru.hadoop.week2;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataInputStream;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

import java.io.IOException;
import java.net.URI;

/**
 * Created by fan.shijun on 2015-04-13.
 */
public class Fscat {

    public static void main(String[] args) throws IOException {
        //String urisrc = args[0];
        //String uridst = args[1];
        //String urisrc = "file:///D:/logs/LM.log";
        String urisrc = "hdfs://10.61.3.113:9000/input/ncdc/010010-99999-2015.txt";
        String uridst = "file:///D:/logs/test2.txt";
        Configuration conf = new Configuration();
        FileSystem fsin = FileSystem.get(URI.create(urisrc), conf);
        FileSystem fsout = FileSystem.get(URI.create(uridst), conf);
        FSDataInputStream in = null;
        FSDataOutputStream out = null;
        in = fsin.open(new Path(urisrc));
        //out = fsout.create(new Path(uridst), true);
        in.seek(0);
        //IOUtils.copyBytes(in, out, Long.valueOf(20), 4096, true);
        IOUtils.copyBytes(in,System.out,Long.valueOf(20),true);
    }

}
